﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
public partial class aspnet_admin_bock_News_NewsListDataSource : System.Web.UI.Page
{

            /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();

    /// <summary>
    ///分页
    /// </summary>
    Tong.Fy.FenYe FY = new Tong.Fy.FenYe();
    public int contpages = 0;

    /// <summary>
    /// 显示问题的类型
    /// </summary>
    public string Type = "n";//n 最新 ,z 0回答问题 ,u 新手 , f 高分

    

    public string CoulmnID = "";//栏目ID
    protected void Page_Load(object sender, EventArgs e)
    {
        string sql = "";
        try//得到类型
        {
            Type = Request.QueryString["Type"].Trim();
            CoulmnID = Request.QueryString["status"].Trim();//栏目ID
        }
        catch
        {

        }
        if (CoulmnID != "")
        {
            #region 输出不同的SQL
            if (Type == "n")//n 最新
            {
                sql = "select * from [CX_News] where [CX_NEWS_Class_id] in  (SELECT [CX_NEWS_Class_id] FROM [CX_NEWS_Class] where [CX_Column_id]=" + CoulmnID + ")";
            }
            if (Type == "r" && CoulmnID.Trim()!="")//r 搜索
            {
                sql = "select * from [CX_News] where [CX_NEWS_Name] like'%" + CoulmnID + "%' order by CX_NEWS_Sort desc,CX_NEWS_PublicTime desc,CX_NEWS_id desc";
            }
            #endregion

            try
            {
                contpages = int.Parse(TextData.SqlataSet(sql).Tables[0].Rows.Count.ToString());
            }
            catch
            {

            }
        }


        Repeater1.DataSource = FY.Fy(sql, 500);//分页
        Repeater1.DataBind();
        Response.ContentType = "text/xml";
    }
    /// <summary>
    /// 用于返回 新闻 类型 
    /// </summary>
    /// <param name="sid"></param>
    /// <returns></returns>
    public string GetNewsType(string strx, string lx)
    {


        string cstrx = "";
        if (strx == "1" && lx == "CX_NEWS_Top")
        {
            cstrx = " 头条新闻 , ";
        }

        if (strx == "1" && lx == "CX_NEWS_Pic")
        {
            cstrx = " 图片新闻 , ";
        }

        return cstrx;
    }
    
    /// <summary>
    /// 用于设定
    /// </summary>
    /// <param name="sid"></param>
    /// <returns></returns>
    public string GetColumn(string sid)
    {
        try
        {
            //如果没有新闻分类
            return TextData.SqlataSet("select top 1 * from [CX_NEWS_Class] where CX_NEWS_Class_id=" + sid).Tables[0].Rows[0]["CX_NEWS_Class_Name"].ToString();
        }
        catch
        {
            return "不存在新闻设定，程序将不能完成操作";
        }
    }
    

}
